package com.example.Controller;

import com.example.event.GenericEvent;
import com.example.listener.StringEventListener;
import com.example.listener.ConditionalEventListener;
import com.example.publisher.CustomEventPublisher;
import com.example.publisher.StringEventPublisher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 调用事件发布者
 */
@RestController
public class TestEventListenerController {

    @Autowired
    private CustomEventPublisher publisher;

    @Autowired
    private StringEventPublisher stringEventPublisher;

    @RequestMapping(value = "/test/testPublishEvent1" )
    public void testPublishEvent(){
        publisher.publishEvent("我来了！");
    }

    @RequestMapping(value = "/test/testPublishEvent2" )
    public void testPublishEvent1(){
        stringEventPublisher.publishEvent("string我来了111！");
    }

    @RequestMapping(value = "/test/testPublishEvent3" )
    public void testPublishEvent3(){

        stringEventPublisher.publishEvent("important");
    }


    @RequestMapping(value = "/test/testPublishEvent4" )
    public void testPublishEvent4(){

        stringEventPublisher.publishEvent("async");
    }
}
